package com.tsyz.servlet.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 三方异常类
 *
 * @author ext.zhaoke14
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class BusinessException extends RuntimeException {

    /**
     * 错误码
     */
    private final Integer code;
    /**
     * 标题,可为空
     */
    private final String title;
    /**
     * 错误内容,可为空
     */
    private final String message;


    public BusinessException(ErrorEnumCode errorEnumCode) {
        super(errorEnumCode.getMessage());
        this.code = errorEnumCode.getCode();
        this.message = errorEnumCode.getMessage();
        this.title = errorEnumCode.getTitle();
    }

    public BusinessException(ErrorEnumCode errorEnumCode, String message) {
        super(message);
        this.code = errorEnumCode.getCode();
        this.title = errorEnumCode.getTitle();
        this.message = message;
    }

}
